package com.julius.design.suanfa.str;

/**
 * @author julius
 * @date 2021-10-21 上午 10:09
 * <p>
 *      替换空格
 * </p>
 */
public class ReplaceSpace {


    /**
     * 替换空格为 %20
     * @param s
     * @return
     */
    public String replaceSpace(String s){
        if(s == null){
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0;i< s.length();i++){
            Character character = s.charAt(i);
            if(character == ' '){
                stringBuilder.append("%20");
            }else{
                stringBuilder.append(character);
            }
        }
        return stringBuilder.toString();

    }
}
